import {createStore} from "vuex"

const state = function(){
  return {
    noteList : [],
    loginFlag:false,
    user:{
      id:"",
      name:"",
      signature:"",
      email:"",
      avatar:"",
      sex:"",
      password:"",
    },
    myNotes : {},
    taNotes : {},
    detail : {}
  }
}

const getters = {

}

const mutations = {
  getNote(state,list){
    state.noteList = list
  },
  flag(state,flg){
    state.loginFlag = flg
  },
  userMsg(state,userObj){
    state.user = userObj
  },
  myNotes(state,notes){
    state.myNotes = notes
  },
  taNotes(state,notes){
    state.taNotes = notes
  },
  detail(state,note){
    state.detail = note
  }
}

const actions = {
  getNote(context,data){
    context.commit("getNote",data.data.data)
  },
  myNotes(context,notes){
    context.commit("myNotes",notes)
  },
  taNotes(context,notes){
    context.commit("taNotes",notes)
  },
}


const store = createStore({
  state,
  getters,
  mutations,
  actions
})

export default store